<template>
	<view class="data-box">
		<!-- 列表头部 -->
		<view class="data-fixed-box">
			<!-- 搜索 -->
			<search @searchText="searchText" 
				:placeholder="placeholder" 
				:showAddGoods="showAddGoods" 
				:md="cgKd"
				@openObjTypeList= "openObjTypeList"
				@searchAction="searchAction" 
				@inputSearchKw="inputSearchKw"
				@inputFocus="inputFocus"
				@setTitleValue="setTitleValue"
				ref="search">
			</search>
				
			<!-- 切换产品列表，供应商列表-->
			<changeList ref="gdSuppTab" 
						@changeList="changeList" 
						v-show="seeSupplier && !isCheckOut && !isSearching">
			</changeList>
			
			<!-- 产品列表过滤 -->
			<filters v-show="selectListId == 1 && isShowFilters && !isSearching" 
					ref="filtersBox"
					@setCat="setCat" 
					@setStoreId="setStoreId"
					@setGoods="setGoods" 
					@followAndbrand="followAndbrand"
					@setListBoxHeight="setListBoxHeight"
					:md="cgKd"
					:filltersData="filltersData" 
					:storeLs="storeLs"
					:showFiltersGoodsState="showGoodsState"
					:yunList="yunLs"
					:brandList="brandLs"
					:tagsList="tagsLs">
			</filters>
			
			<!-- 供应商过滤 -->
			<supplierFilters v-show="selectListId == 2 && isShowFilters && !isSearching" 
				:topVal="suppFilterTopVal"
				:limitViewOtherSupp="limitViewOtherSupp"
				@setSuppCate="setSuppCate"
				@setSortId="setSortId"
				@setUcpId="setUcpId"
				ref="supplierFiter">
			</supplierFilters>
			
			<!-- 搜索类型下拉弹出 -->
			<searchTotal :total="total" v-show="isSearching"></searchTotal>
			
			<!-- 搜索类型下拉弹出 -->
			<searchPop ref="searchPop"
				:type="searchGdAndSuppType"
				@changeObjType="changeObjType" 
				@showAndHideTypeList="showAndHideTypeList"
				@setDefaultObjType="setDefaultObjType">
				
			</searchPop>
			<!-- 关键字搜索结果 -->
			<searchKwResult ref="searchKwResult" @doSearch="doSearch"></searchKwResult>
		</view>
		
		<!-- 产品列表 -->
		<goodsList @setGoodsInfoData="setGoodsInfoData" 
			ref="setGoodsId"
			:topValue="gdLstopVal"		
			:goodsLs="goodsLs"
			:md="cgKd"
			:allowViewStore="allowViewStore"
			@getGoodsList="getGoodsList"
			@searchGdsCatAndKwList="searchGdsCatAndKwList"
			:isSearching="isSearching" 
			v-show="selectListId == 1">
		</goodsList>
		
		<!-- 供应商列表 -->
		<supplierList :list="suppList"
		    ref="setSuppplierId"
			:md="cgKd"
			:isShowName="isShowName"
			:isShowCp="isShowCp"
			@getSuppList= "getSuppList"
			@searchSuppCatAndKwList="searchSuppCatAndKwList"
			@setSuppmInfo="setSuppInfoData"
			:topValue="suppListTopval"
			:isSearching="isSearching" 
			v-show="selectListId == 2">
		</supplierList>
		
		<!-- 监听扫码枪 -->
	</view>
</template>

<script>
	import search from "../comm/Search.vue";
	
	import filters from "../goods/Goodsfilters.vue";
	
	import supplierFilters from "../comm/SupplierFilters.vue";
	
	import goodsList from "../goods/GoodsList.vue";
	
	import supplierList from "../comm/SupplierList.vue";
	
	import staticConst from "../../js/const/StaticConst.js";
	
	import config from "../../js/conf/Config.js";
	
	import catList from "../../js/gd/CatList.js";
	
	import eventCtrl from "../../js/event/EventCtrl.js";
	
	import https from "../../js/https/Https.js";
	
	import accessCtrl from "../../js/limit/AccessCtrl.js";
	
	import lang from "../../js/conf/Lang.js";
	
	import searcher from "../../js/search/Searcher.js";
	
	import searchPop from "../comm/SearchPop.vue";
	
	import searchKwResult from "../comm/SearchKwResult.vue";
	
	import searchTotal from "../comm/SearchTotal.vue";
	
	import changeList from "./PurchaseChangeList.vue";
	
	import supplierCtrl from "../../js/supplier/SupplierCtrl.js";
	
	import localStore from "../../js/LocalStore.js";
	
	
	
	let pageNo = 0;
	let pageSize = staticConst.PAGE_SIZE;
	let custPage = 0;
	export default {
		components: { search , 
					  filters , 
					  supplierFilters,
					  goodsList, 
					  searchPop, 
					  searchTotal, 
					  searchKwResult,
					  changeList,
					  supplierList},
		data() {
			return {
				
				seeSupplier:true,
				
				gdLstopVal:150, //产品列表距离顶部高度
				
				suppListTopval : 150,//供应商列表距离顶部的高度
				suppFilterTopVal : 130, //供应商过滤距离顶部的高度
				
				selectListId : 1,
				
				cgKd : staticConst.CG_KD, //采购开单模块
				
				isShowFilters : true,//是否显示过滤栏
				showGoodsState : true,//filters组件的状态过滤显示
				goodsData : {
					is_sale:"",//是否用于开单 1 是 2否 1 的时候返回所有app上架产品
					catid:"",//分类
					brand : "",//品牌
					code:"",//条码值
					qty:"",//是否有货 1 是2否
					onsale:"",//是否在app上架 预留
					onsale_yd:"",//是否云店上架 1是2否
					attention : "",//筛选菜蔬 1 ：30天内未销售的产品 2： 7天内发布的产品 3：30天内发布的产品
					kw : '',//搜索关键词
					storeid : '',//仓库Id
				},
				goodsLs : [],//产品列表
				storeLs : [],//仓库分类列表
				yunLs : [],//云店列表
				brandLs:[],//品牌
				tagsLs:[],//标签
				filltersData : {
					cat : "类别",
					store : "全部仓库",
					inStock : "全部产品",
					screening : "筛选",
					statisticalIndex : 2,
					TimeStateIndex : '',
					StoresStateIndex : '',
					HandlersStateIndex : '',
				},
				placeholder:"搜索货号/品名/货名/备注",
				BoxHeight : false,
				showAddGoods : false,
				
				isSearching :false,
				objType:null,
				keyWord:"",
				total:0,
				exactKw:null,
				
				//加载供应商列表
				suppData:{
					typeid: 'all', //供应商类型
					orderby: "", //排序 1 创建时间 2 欠款额度 3 交易单数 4最近交易
					uid_cp: "", //	经手人
					group: "", //	非必须 筛选 1 30天内没消费供应商 2 30天内新增供应商
					idyun: "", //	云店id 非筛选项 不传该参数
					isyun:"", //	是否为云店供应商 1是其他 否 非筛选项 不传该参数
					is_yy:"", //是否为预约 1是 其他否 默认否
					pfrom: 0, //	开始id 非必须 默认为0
					pnum: pageSize,	//每页数量 非必须 默认0
					province: "", //	省份搜索 int 省份code 非筛选项 不传该参数
					city: "", //城市搜索 int 市code 非筛选项 不传该参数
					area: "", //区域搜索 int 区域code 非筛选项 不传该参数
					suppid:"",//搜索供应商id
					tagid:"", //标签id 非筛选项 不传该参数
				},
				
				suppList:[], //供应商列表
				searchGdAndSuppType:1, //1:产品，2：单据， 3：客户，4:供应商
				
				suppId : 0,//供应商id；
				isCheckOut : false, //是否是结算
				
				limitViewOtherSupp : true,
				isLoading : false,
				
				mySelf:null,
				
				isShowCp:true,//是否显示供应商公司名称
				isShowName:true,//是否显示供应商名称
				allowViewStore:true,
			};
		},
		
		methods: {
			
			/**********监听数码枪***************/
			scanGunHandler()
			{
				this.scanGunCtrl.curAct = 2;
				this.scanGunCtrl.receiptCallBack = this.scanCallBack;
			},
			
			/****产品扫码加购返回*****/
			scanCallBack(keyCode)
			{
				this.clearGoodsList();
				if(this.$refs.search)
					this.$refs.search.setCatSearchTxt(keyCode);
				this.scanGunSearchGdsList(keyCode);
			},
			
			/***初始化列表***/
			async initData()
			{
				this.scanGunHandler();
				this.seeSupplier = await accessCtrl.getPurchViewSupplierLimit();
				this.gdLstopVal =  this.seeSupplier ? 150 : 110; //产品列表距离顶部高度
				this.allowViewStore = await accessCtrl.getPurchViewQtyEditLimit();
				this.mySelf = await localStore.getUserInfo();
				this.limitViewOtherSupp = await accessCtrl.getPurchViewSupplierLimit();
				this.showAddGoods = await accessCtrl.getGdsAddLimit();
				this.resetSeachCustData();
				this.clearGoodsList();
				this.clearSupplierList();
				this.getGoodsList();
				await this.getSuppList();
				await searcher.loadGdsSchObjTypeLs(searcher.CH_SUPP);
				await searcher.loadGdsSchObjTypeLs(searcher.CH_GD);
			},
			
			resetSeachCustData()
			{
				this.suppData = {
					typeid: 'all', //供应商类型
					orderby: "", //排序 1 创建时间 2 欠款额度 3 交易单数 4最近交易
					uid_cp: "", //	经手人
					group: "", //	非必须 筛选 1 30天内没消费供应商 2 30天内新增供应商
					idyun: "", //	云店id 非筛选项 不传该参数
					isyun:"", //	是否为云店供应商 1是其他 否 非筛选项 不传该参数
					is_yy:"", //是否为预约 1是 其他否 默认否
					pfrom: 0, //	开始id 非必须 默认为0
					pnum: pageSize,	//每页数量 非必须 默认0
					province: "", //	省份搜索 int 省份code 非筛选项 不传该参数
					city: "", //城市搜索 int 市code 非筛选项 不传该参数
					area: "", //区域搜索 int 区域code 非筛选项 不传该参数
					suppid:"",//搜索供应商id
					tagid:"", //标签id 非筛选项 不传该参数
				};
			},
			
			setGdSuppIdNull()
			{
				this.$refs.setSuppplierId.setGdSuppIdNull();
				this.$refs.setGoodsId.setGoodIdIsNull();
			},
			
			/***选择供应商列表****/
			selectedSuppGoodsList(value)
			{
				this.$refs.gdSuppTab.updateIndx(value);
				this.changeList(value);
			},
			
			/****分类筛选****/
			setSuppCate(id)
			{
				this.clearSupplierList();
				this.suppData.typeid = id;
				this.getSuppList();
			},
			
			/***排序赛选***/
			setSortId(id)
			{
				this.clearSupplierList();
				this.suppData.orderby = id;
				this.getSuppList();
			},
			
			/****经手人筛选****/
			setUcpId(id)
			{
				this.clearSupplierList();
				this.suppData.uid_cp = id;
				this.getSuppList();
			},
			
			/***供应商列表***/
			getSuppList()
			{
				let that = this;
				if(this.isLoading)return;
				if(!this.limitViewOtherSupp && this.mySelf)
				{
					this.suppData.uid_cp = this.mySelf.uid;
				}
				
				this.isLoading = true;
				this.suppData.pfrom = custPage * pageSize;
				supplierCtrl.getSuppList(this.suppData,back);
				function back(data)
				{
					that.isLoading = false;
					
					data = data.data;
					
					supplierCtrl.setIsShowCp(data.is_cp);
					supplierCtrl.setIsShowName(data.is_name);
					
					that.isShowCp = supplierCtrl.getIsShowCp();
					that.isShowName = supplierCtrl.getIsShowName();
					if(data.supp_ls && data.supp_ls.length > 0)
					{
						that.suppList = that.suppList.concat(data.supp_ls);
						custPage ++;
					}
					
					let obj = {};
					if(data.custype_ls)
					{
						data.custype_ls.unshift({id:"",title:"全部"});
						data.custype_ls.push({id:"0",title:"未分类"});
						obj.cateList = data.custype_ls;
					}
					
					if(data.order_ls)
					{
						obj.customSortList = data.order_ls;
						let len = data.order_ls.length;
						for(let i = 0; i < len; i++)
						{
							let temp = data.order_ls[i];
							if(temp.is_ck == 1)
							{
								obj.customSortCheckId = temp.id;
								break;
							}
						}
					}
					that.$refs.supplierFiter.initData(obj);
				}
			},
			
			clearSupplierList()
			{
				custPage = 0;
				this.suppList = [];
			},
			
			/****切换列表****/
			changeList(id)
			{
				this.selectListId = id;
				if(!this.isCheckOut)
				{
					this.objType = null;
					this.$refs.searchPop.setCurCodeNull();
				}
				if(this.selectListId == 1)
				{
					this.placeholder = "搜索产品";
					this.searchGdAndSuppType = 1;
				}
				else
				{
					if(!this.isCheckOut)
						this.placeholder = "搜索供应商";
					this.searchGdAndSuppType = 4;
				}
			},
			
			/***弹出搜索类型列表***/
			openObjTypeList(value)
			{
				this.searchAction(true);
				if(value)
				{
					this.$refs.searchPop.show("show");
					if(this.objType)
						this.placeholder = "请输入" + this.objType.name;
				}
				else
				{
					this.$refs.searchPop.show();
				}
			},
			
			/***设置输入框，选择的搜索关键字值****/
			setTitleValue(item)
			{
				this.$refs.search.setCatSearchTxt(item.title);
			},
			
			/*****搜索产品****/
			doSearch(item,listType)
			{
				if(this.selectListId == 1)
					this.clearGoodsList();
				else
					this.clearSupplierList();
				let data = {};
				data.listType = listType;
				this.$refs.search.setCatSearchTxt(item.title);
				if(listType == 0)
				{
					data.exact = 1;
					data.kw = item.title;
				}
				else
				{
					data.exact = 2;
					data.kw = "";
					if(this.selectListId == 1)
						data.catid = item.id;
					else 
						data.typeid = item.id;
				}
				this.exactKw = data;
				if(this.selectListId == 1)
					this.searchGdsCatAndKwList();
				else
					this.searchSuppCatAndKwList();
			},
			
			/****按分类或关键字搜索产品****/
			searchGdsCatAndKwList()
			{
				if(!this.exactKw)return;
				if(this.isLoading)return;
				this.isLoading = true;
				let that = this;
				let obj = {};
				obj.exact = this.exactKw.exact;
				obj.kw = this.exactKw.kw;
				obj.suppid = this.suppId;
				if(this.exactKw.listType == 0)
				{
					if(this.objType)
						obj.objtype = this.objType.code;
				}
				else
				{
					obj.objtype = "";
					obj.catid = this.exactKw.catid;
				}
				obj.pfrom = pageNo * pageSize;
				obj.pnum = pageSize;
				https.searchGdsCatAndKwList(obj,callBack);
				function callBack(data)
				{
					that.isLoading = false;
					if(data && data.status == 1)
					{
						if(!data.data) return;
						data = data.data;
						if(data.total)
							that.total = data.total;
						if(!data.goods_ls)return;
						if(data.tag_ls && pageNo == 0)
						{
							that.tagsLs = that.filterDataFormat (lang.tagTxt.title,data.tag_ls);
						}
						that.goodsLs = that.goodsLs.concat(data.goods_ls);
						pageNo ++;
					}
				}
			},
			
			/****按分类或关键字搜索供应商****/
			searchSuppCatAndKwList()
			{
				if(!this.exactKw)return;
				if(this.isLoading)return;
				this.isLoading = true;
				let that = this;
				let obj = {};
				obj.exact = this.exactKw.exact;
				obj.kw = this.exactKw.kw;
				obj.typeid = this.exactKw.typeid;
				if(this.exactKw.listType == 0)
				{
					if(this.objType)
						obj.objtype = this.objType.code;
				}
				else
				{
					// obj.objtype = "";
					if(this.objType)
						obj.objtype = this.objType.code;
				}
				obj.pfrom = custPage * pageSize;
				obj.pnum = pageSize;
				https.searchSuppCatAndKwList(obj,callBack);
				function callBack(data)
				{
					that.isLoading = false;
					if(data && data.status == 1)
					{
						if(!data.data) return;
						data = data.data;
						if(data.total)
							that.total = data.total;
						if(!data.supp_ls)return;
						that.suppList = that.suppList.concat(data.supp_ls);
						custPage ++;
					}
				}
			},
			
			/***是否搜索****/
			searchAction(value)
			{
				this.isSearching = value;
				if(!value)
				{
					this.$refs.searchPop.show();
					this.exactKw = null;
					this.keyWord = "";
					this.total = 0;
					this.$refs.search.clearSearchTxt();
					this.$refs.searchKwResult.setListData([]);
					this.$refs.searchKwResult.setListData("");
					if(this.selectListId == 1)
					{
						this.clearGoodsList();
						this.placeholder = "搜索产品";
						this.getGoodsList();
					}
					else
					{
						this.clearSupplierList();
						this.placeholder = "搜索供应商";
						this.getSuppList();
					}
				}
				// this.checkOut(value);
				if(!this.isCheckOut)
					this.setGgCustLsTopval(value);
				else
					this.checkOut(this.isCheckOut);
			},
			
			/***输入关键字搜索*****/
			inputSearchKw(kw)
			{
				let data = {};
				let that = this;
				this.keyWord = kw;
				data.kw = kw;
				if(this.objType)
					data.objtype = this.objType.code;
				if(this.selectListId == 1)
					data.ch = searcher.CH_GD;
				else
					data.ch = searcher.CH_SUPP;
				https.searchKwByObjType(data,callBack);
				function callBack(obj)
				{
					if(obj.status == 1)
					{
						that.$refs.searchKwResult.setKeyWord(that.keyWord);
						if(obj.data && obj.data.ls && obj.data.ls.length)
						{
							that.$refs.searchKwResult.setListData(obj.data.ls);
						}
						else
						{
							that.$refs.searchKwResult.setListData([]);
						}
					}
					else
					{
						that.$refs.searchKwResult.setListData([]);
					}
				}
			},
			
			/*****输入框获取焦点处理****/
			inputFocus(inputTxt)
			{
				this.$refs.searchPop.init();
				if(this.objType)
					this.placeholder = "请输入" + this.objType.name;
				this.$refs.search.searchAction(true);
				if(inputTxt == "")
				{
					let list = searcher.getCatList(); 
					if(this.selectListId == 2)
						list = searcher.getSuppCatList();
					if(!this.isCheckOut)
					{
						let listType = 1; //listType 1:分类列表
						this.$refs.searchKwResult.setListData(list,listType); 
					}
				}
			},
			
			/***改变搜索类型***/
			changeObjType(item)
			{
				this.placeholder = "请输入" + item.name;
				this.objType = item;
				this.$refs.searchPop.show();
			},
			
			/****显示或隐藏类型列表****/
			showAndHideTypeList(value)
			{
				this.$refs.search.setIsOpenList(value);
			},
			
			/****初始化设置默认objType*****/
			setDefaultObjType(item)
			{
				this.objType = item;
			},
			
			/*** 根据筛选重新设置list盒子高度 ***/
			setListBoxHeight(data)
			{
				this.BoxHeight = data;
			},
			
			/***清除产品列表****/
			clearGoodsList()
			{
				pageNo = 0;
				this.goodsLs = [];
			},
			
			/*** 搜索 ***/
			searchText(kw)
			{
				let item = this.getSelectedKwTitle();
				this.$refs.searchKwResult.setShowValue(false);
				if(this.selectListId == 1)
					this.clearGoodsList();
				else 
					this.clearSupplierList();
				let data = {};
				if(item != null)
				{
					this.keyWord = item.title;
					data.exact = 1;
					this.$refs.search.setCatSearchTxt(item.title);
				}
				else
				{
					this.keyWord = kw;
					data.exact = 2;
				}
				data.listType = 0;
				data.kw = this.keyWord;
				this.exactKw = data;
				if(this.selectListId == 1)
					this.searchGdsCatAndKwList();
				else
					this.searchSuppCatAndKwList();
			},
			
			/*****获取选择的关键字****/
			getSelectedKwTitle()
			{
				let item = this.$refs.searchKwResult.getSelectedItem();
				return item;
			},
			
			/****选择产品*****/
			setGoodsInfoData(data)
			{
				this.$emit("setGoodsThree",data);
			},
			
			/****选择供应商****/
			setSuppInfoData(item,index)
			{
				this.$emit("setSuppmInfo",item,this.isCheckOut);
			},
			
			/*** 分类搜索 ***/
			setCat(id)
			{
				this.clearGoodsList();
				this.goodsData.catid = id;
				this.getGoodsList();
			},
			
			/*** 设置产品筛选  ***/
			setGoods(res)
			{
				this.clearGoodsList();
				this.goodsData.qty = res;
				this.getGoodsList();
			},
			
			/*** 筛选关注  or  品牌 ,云店，标签，***/
			followAndbrand(data)
			{
				this.clearGoodsList();
				this.goodsData.attention = "";
				this.goodsData.brand = "";
				this.goodsData.idyun = "";
				this.goodsData.tagid = "";
				if(data.attention != -1)//关注
					this.goodsData.attention = data.attention;
				if(data.brand != -1)//品牌
					this.goodsData.brand = data.brand;
				if(data.idyun != -1)
					this.goodsData.idyun = data.idyun;
				if(data.tagid != -1)
					this.goodsData.tagid = data.tagid;
				this.getGoodsList();
			},
			
			/*** 设置仓库筛选 ***/
			setStoreId(id)
			{
				this.clearGoodsList();
				this.goodsData.storeid = id;
				this.getGoodsList();
			},
			
			/*** 获取产品列表  GOODS_LIST ***/
			async getGoodsList()
			{
				if(this.isLoading)return;
				this.isLoading = true;
				let url = config.STORE_GOODS_LS;//config.GOODS_LIST;
				let param = {};

				param = this.goodsData;
				param.pfrom = pageNo * pageSize;
				param.pnum = pageSize;
				let res = await this.$api({url:url,data:param});
				console.log('产品列表==============================>',res);
				this.isLoading = false;
				if(!res || !res.data)
				{
					if(pageNo == 0)
					{
						this.$emit("setGoodsThree");
					}
					return;
				} 
	
				if(res.data.cat_ls)
				{
					catList.list = res.data.cat_ls;
				}	
					
				if(res.data.store_ls && pageNo == 0)
					this.storeLs = res.data.store_ls;
				
				if(res.data.yd_ls  && pageNo == 0)
				{
					this.yunLs = this.filterDataFormat (lang.ydTxt,res.data.yd_ls);
				}
				
				if(res.data.brand_ls  && pageNo == 0)
				{
					this.brandLs = this.filterDataFormat (lang.brandTxt.title,res.data.brand_ls);
				}
				
				
				if(res.data.tag_ls  && pageNo == 0)
				{
					this.tagsLs = this.filterDataFormat (lang.tagTxt.title,res.data.tag_ls);
				}
				if(res.data.goods_ls)
				{
					this.goodsLs = this.goodsLs.concat(res.data.goods_ls);
					pageNo ++;
				}
			},
			
			filterDataFormat(title, arr)
			{
				let tempArr = [];
				let data = {};
				data.title = title;
				let ary = [];
				if(arr)
				{
					for(let i=0;i<arr.length;i++)
					{
						let obj =  arr[i];
						let temp = {};
						if(obj.hasOwnProperty('idyun'))
							temp.id = obj.idyun;
						if(obj.hasOwnProperty('id'))
							temp.id = obj.id;
						if(obj.hasOwnProperty("name"))
							temp.title = obj.name;
						if(obj.hasOwnProperty("title"))
							temp.title = obj.title;
						ary.push(temp);
					}
				}
				data.ls = ary;
				tempArr.push(data);
				return tempArr;
			},
			
			/***注册时间***/
			addEvent()
			{
				uni.$on(eventCtrl.ACTION_GOODS_EVENT,this.actionHandler);
			},
			
			removeEvent()
			{
				uni.$off(eventCtrl.ACTION_GOODS_EVENT);
			},
			
			/****处理操作菜单***/
			actionHandler(data)
			{
				this.removeEvent();
				this.addEvent();
				let i,len = this.goodsLs.length;
				for(i = 0; i<len; i++)
				{
					let obj = this.goodsLs[i];
					if(obj.id == data)
					{
						this.goodsLs.splice(i,1);
						break;
					}
				}
				len = this.goodsLs.length;
				if(len > 0)
				{
					let index = 0;
					if(len > 1)
					{
						if(i>1)
						{
							index = i - 1;
						}
						else
						{
							index = i;
						}
					}
					let obj = this.goodsLs[index];
					if(obj)
					{
						this.setGoodsInfoData(obj);
					}
				}
			},
			
			/*****更新列表数据*****/
			updateListData(gdInfo)
			{
				let i,len = this.goodsLs.length;
				for(i = 0; i<len; i++)
				{
					let obj = this.goodsLs[i];
					if(obj.id == gdInfo.id)
					{
						// this.goodsLs.splice(i,1);
						obj.imgs = gdInfo.imgs;
						obj.title = gdInfo.title;
						obj.qty = gdInfo.qty;
						obj.tagsInfo = gdInfo.tagsInfo;
						obj.price =  gdInfo.price;
						break;
					}
				}
			},
			
			onClickPageHandler(event)
			{
				if(this.isSearching)return;
				let detail = event.detail;
				if(detail.x < 72 || detail.x > 437 || detail.y < 70)
				{
					this.$refs.filtersBox.onClickPageHandler(event);
				}
			},
			
			setGoodIdIsNull()
			{
				this.$refs.setGoodsId.setGoodIdIsNull();
			},
			
			setGgCustLsTopval(value)
			{
				if(this.seeSupplier)
				{
					this.gdLstopVal =  value ? 110 : 150;
					this.suppListTopval = value ? 110 : 150;
					this.suppFilterTopVal = value ? 90 : 130;
				}
				else
				{
					this.gdLstopVal =  110;
					this.suppListTopval = 110;
					this.suppFilterTopVal = 90;
				}
			},
			
			checkOut(value)
			{
				if(this.seeSupplier)
				{
					this.suppListTopval = value ? 110 : 150;
					this.suppFilterTopVal = value ? 90 : 130;
				}
				else
				{
					this.suppListTopval = 110;
					this.suppFilterTopVal = 90; 
				}
				let val = value ? 2 : 1;
				this.selectedSuppGoodsList(val);
				this.isCheckOut = value;
			},
			
			/****扫码强搜索产品****/
			scanGunSearchGdsList(keyCode)
			{
				this.isLoading = true;
				let that = this;
				let param = {};
				param.exact = 1;
				param.kw = keyCode;
				param.suppid = this.suppId;
				param.objtype = "barcode";
				param.pfrom = pageNo * pageSize;
				param.pnum = pageSize;
				https.searchGdsCatAndKwList(param,callBack);
				function callBack(data)
				{
					that.isLoading = false;
					if(data && data.status == 1)
					{
						if(!data.data) return;
						data = data.data;
						if(data.total)
							that.total = data.total;
						if(!data.goods_ls)
						{
							that.scanGunCtrl.rKeyCode = keyCode;
							that.$emit("addNewGoods"); //添加新产品
							return;
						}
						
						if(data.tag_ls && pageNo == 0)
						{
							that.tagsLs = that.filterDataFormat (lang.tagTxt.title,data.tag_ls);
						}
						that.goodsLs = that.goodsLs.concat(data.goods_ls);
						if(that.goodsLs.length == 1)
						{
							let goodsData = that.goodsLs[0];
							that.$refs.setGoodsId.setGoodId(goodsData.id);
							that.$emit("scanGunSelectGds",goodsData);
						}
						pageNo ++;
					}
				}
			},
			
			
		},
		mounted() {
			this.addEvent();
		},
	}
</script>
<style lang="scss">
.data-box
{
	position: fixed;
	margin-left: 0;
	box-sizing: border-box;
	width: 344px;
	height: 100vh;
	border-right: 1px solid #ECECEC;
	.data-fixed-box
	{	
		width: 344px;
		box-sizing: border-box;
		border-right: 1px solid #ECECEC;
		position: fixed;
		top: 0;
		background: #FFF;
		z-index: 1;
	}
}
</style>